<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">编辑生成代码模板模块信息</li>
            </ol>
          </div>
        </div>
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="pull-right h-btn-group">
              <!-- <button class="btn btn-info" id="return-btn" onclick="returnIndex()" ><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>返回</button>
                <button class="btn btn-info" id="save" type="button" onclick="SystemTemplateModuleInfoMgr.submitForm()"><i class="fa fa-save">&nbsp;&nbsp;</i>保存</button> -->
            </div>
          </form>
        </div>

        <div class="form-horizontal  h-form-warp">
          <div class="h-msg-title h-table-header">
            <strong>生成代码模板模块信息</strong>
          </div>
          <form action="/systemTemplateModuleInfo/saveSystemTemplateModuleInfo" class="form-horizontal"
                id="systemTemplateModuleInfoForm"
                method="post" role="form">
            <input id="operation" name="operation" type="hidden" value="${operation!}"/>
            <input class="form-control" id="id" name="id" type="hidden" value="${systemTemplateModuleInfo.id!}"/>
            <input class="form-control" id="templateId" name="templateId" type="hidden"
                   value="${systemTemplateModuleInfo.templateId!}"/>
            <div class="form-group">
              <label class="col-sm-2 col-md-2 col-xs-2 control-label">模板模块编码：</label>
              <div class="col-sm-8 col-md-8 col-xs-8">
                <input class="form-control" id="templateModuleCode" name="templateModuleCode"
                       required="required" type="text"
                       value="${systemTemplateModuleInfo.templateModuleCode!}"/>
              </div>
              <div class='col-sm-2'>
                <input class="primary-btn" id="selectModuleList"
                       onclick="SystemTemplateModuleInfoMgr.selectTemplateModuleList()"
                       type="button"
                       value='请选择'/>
              </div>
              <div class="col-sm-1 col-md-1 col-xs-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-md-2 col-xs-2 control-label">生成文件名称：</label>
              <div class="col-sm-8 col-md-8 col-xs-8">
                <input class="form-control" id="templateModuleName" name="templateModuleName"
                       required="required" type="text"
                       value="${systemTemplateModuleInfo.templateModuleName!}"/>
              </div>
              <div class="col-sm-1 col-md-1 col-xs-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-md-2 col-xs-2 control-label">模块所属模板类型：</label>
              <div class="col-sm-8 col-md-8 col-xs-8" defaultValue='java' dicType='select'
                   dict="template_type"
                   id="templateModuleTypeGroup" name="templateModuleTypeGroup"
                   required="required" value="${systemTemplateModuleInfo.templateModuleType!}">
              </div>
              <div class="col-sm-1 col-md-1 col-xs-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-md-2 col-xs-2 control-label">文件输出绝对路径：</label>
              <div class="col-sm-8 col-md-8 col-xs-8">
                <input class="form-control" id="outputFolder" name="outputFolder"
                       placeholder="/xxx/xx" required="required"
                       type="text" value="${systemTemplateModuleInfo.outputFolder!}"/>
              </div>
              <div class="col-sm-1 col-md-1 col-xs-1">
                <span class="required">*</span>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 col-md-2 col-xs-2 control-label">备注：</label>
              <div class="col-sm-8 col-md-8 col-xs-8">
                <input class="form-control" id="templateModuleComment" name="templateModuleComment"
                       type="text" value="${systemTemplateModuleInfo.templateModuleComment!}"/>
              </div>
            </div>
            <div class="form-group">
              <input type="hidden" id="templateModuleContent" name="templateModuleContent" />
              <label class="col-sm-2 col-md-2 col-xs-2 control-label">模板内容：</label>
              <div class="col-sm-8">
                <script type="text/plain" id="templateModuleContentEditor" style="width:800px;height:600px;">
                  ${systemTemplateModuleInfo.templateModuleContent!}
              </script>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
</div>
<#include "/common/umeditorlib.html">
<#include "/common/jslib.html">
<!-- 弹窗下拉 -->
<script type="text/javascript">
    function returnIndex() {
        window.location.href = "/systemTemplateModuleInfo/query";
    }

    $(function () {
        // 页面操作类型：add(添加)-edit(编辑)-view(查看)
        var operation = $("#operation").val();
        // 弹出窗体控制
        var api = frameElement.api;
        var W = api.opener;
        SystemTemplateModuleInfoMgr = {
            // 初始化
            init: function () {
                // 查看的时候不显示保存按钮
                if (operation == "view") {
                    Jmts.setFormReadOnly();
                }
                api.button({
                    id: 'ok',
                    name: '保存',
                    callback: SystemTemplateModuleInfoMgr.submitForm
                });
                api.button({
                    id: 'cancel',
                    name: '关闭',
                    callback: function () {
                        W.location.reload();
                    }
                });
                initDict(DICTURL, FORM, operation);
            },
            // init end

            // 提交数据
            submitForm: function () {
                $("#templateModuleContent").val(UM.getEditor('templateModuleContentEditor').getContent());
                Jmts.ajaxSubmit(document.getElementById("systemTemplateModuleInfoForm"), function (result) {
                    if (result.success) {
                        if (operation == 'add') {
                            W.Jmts.succTips(result.msg);
                            W.location.reload();
                            api.close();
                        } else {
                            Jmts.succTips(result.msg);
                            window.location.reload();
                        }
                    } else {
                        Jmts.warnTips(result.msg);
                    }
                });
                return false;
            },
            // submitForm end
            returnIndex: function () {
                window.location.href = "/systemTemplateModuleInfo/query";
            },
            selectTemplateModuleList: function () {
                var url =
                    "/systemTemplateModuleList/selectModuleList?returnMethod=SystemTemplateModuleInfoMgr.initModuleInfo&selectType=single";
                Jmts.openDialog("templateInfoId", url, "选择模板模块", 550, 700, 44);
            },
            initModuleInfo : function(data){
                var moduleInfo = data.split("#");
                $("#outputFolder").val(moduleInfo[2]);
                $("#templateModuleName").val(moduleInfo[1]);
                $("#templateModuleCode").val(moduleInfo[0]);
            }
        };
        // 执行初始化
        SystemTemplateModuleInfoMgr.init();
        // 前台验证表单
        $("#systemTemplateModuleInfoForm").validate();
    });
</script>
<script type="text/javascript">
    //实例化编辑器
    var um = UM.getEditor('templateModuleContentEditor');
    um.addListener('blur',function(){
        $('#focush2').html('编辑器失去焦点了')
    });
    um.addListener('focus',function(){
        $('#focush2').html('')
    });
    //按钮的操作
    function insertHtml() {
        var value = prompt('插入html代码', '');
        um.execCommand('insertHtml', value)
    }
    function isFocus(){
        alert(um.isFocus())
    }
    function doBlur(){
        um.blur()
    }
    function createEditor() {
        enableBtn();
        um = UM.getEditor('templateModuleContentEditor');
    }
    function getAllHtml() {
        alert(UM.getEditor('templateModuleContentEditor').getAllHtml())
    }
    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('templateModuleContentEditor').getContent());
        alert(arr.join("\n"));
    }
    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UM.getEditor('templateModuleContentEditor').getPlainTxt());
        alert(arr.join('\n'))
    }
    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用umeditor')方法可以设置编辑器的内容");
        UM.getEditor('templateModuleContentEditor').setContent('欢迎使用umeditor', isAppendTo);
        alert(arr.join("\n"));
    }
    function setDisabled() {
        UM.getEditor('templateModuleContentEditor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UM.getEditor('templateModuleContentEditor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UM.getEditor('templateModuleContentEditor').selection.getRange();
        range.select();
        var txt = UM.getEditor('templateModuleContentEditor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UM.getEditor('templateModuleContentEditor').getContentTxt());
        alert(arr.join("\n"));
    }
    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UM.getEditor('templateModuleContentEditor').hasContents());
        alert(arr.join("\n"));
    }
    function setFocus() {
        UM.getEditor('templateModuleContentEditor').focus();
    }
    function deleteEditor() {
        disableBtn();
        UM.getEditor('templateModuleContentEditor').destroy();
    }
    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }
    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            domUtils.removeAttributes(btn, ["disabled"]);
        }
    }
</script>
</body>
</html>
